package czx.wt.system.pojo;

import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.ibatis.type.Alias;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Past;
import javax.validation.constraints.Pattern;
import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * @Author: ChenZhiXiang
 * @Date: 2019/6/18 21:18
 * @Description: 用户实体类
 */
@TableName("sys_user")
@Data
@Alias("user")
@NoArgsConstructor
@AllArgsConstructor
@ApiModel(value = "user")
public class User implements Serializable {

    private static final long serialVersionUID = -627315358389199479L;

    @TableId
    @ApiModelProperty(value="用户编码",example="1")
    private Integer userId;

    @NotBlank(message = "用户名不能为空")
    @Length(min = 4,max = 8,message = "用户名长度必须在4~8")
    @ApiModelProperty(value="用户名",example="gjdsf")
    private String username;

    @Pattern(regexp = "^(?![A-Z]+$)(?![a-z]+$)(?!\\d+$)(?![\\W_]+$)\\S{6,16}$",message = "密码由大小写字母、数字、特殊符号的两种及两种以上组成，长度6到16位")
    @ApiModelProperty(value="密码",example="Sfdf@f12")
    private String password;

    @Length(min = 4,max = 8,message = "用户名长度必须在4~8")
    @ApiModelProperty(value="昵称",example="ghfd")
    private String nickName;

    @ApiModelProperty(value="头像",example="ghfd")
    private String avatar;

    @Length(min = 1,max = 2)
    @ApiModelProperty(value="性别 男 女 未知",example="男")
    private String sex;

    @Pattern(regexp = "^((13[0-9])|(14[0-9])|(15[0-9])|(17[0-9])|(18[0-9]))(\\d{8})$",message = "手机号格式不正确")
    @ApiModelProperty(value="手机号",example="13645454431")
    private String phone;

    @Email
    @ApiModelProperty(value="邮箱",example="12054543@qq.com")
    private String email;

    @ApiModelProperty(value="邮箱是否验证，0未验证，1已验证",example="1")
    private Integer emailVerified;

    @ApiModelProperty(value="真实姓名",example="ghfd")
    private String trueName;

    @Pattern(regexp = "^\\d{15}|\\d{18}$",message = "身份证号格式错误")
    @ApiModelProperty(value="身份证号",example="32435********32")
    private String idCard;

    @Past(message = "出生日期不正确")
    @ApiModelProperty(value="出生日期",example="")
    private Date birthday;

    @ApiModelProperty(value="部门id",example="1")
    private Integer departmentId;

    @ApiModelProperty(value="状态，0正常，1冻结 2删除",example="0")
    private Integer state;

    @ApiModelProperty(value="注册时间",example="")
    private Date createTime;

    @ApiModelProperty(value="修改时间",example="")
    private Date updateTime;

    @ApiModelProperty(value="角色",example="")
    @TableField(exist = false)
    private List<Role> roles;

    @TableField(exist = false)
    @ApiModelProperty(value="权限",example="")
    private List<Authorities> authorities;
}
